import request from '@/config/axios'

// 文本内容 VO
export interface ContentTextVO {
  id: number // 文本ID
  menuId: number // 菜单ID
  title: string // 标题
  thumb: string // 封面图
  content: string // 内容
  status: number // 审批结果
}

// 文本内容 API
export const ContentTextApi = {
  // 查询文本内容分页
  getContentTextPage: async (params: any) => {
    return await request.get({ url: `/cms/content-text/page`, params })
  },

  // 查询文本内容详情
  getContentText: async (id: number) => {
    return await request.get({ url: `/cms/content-text/get?id=` + id })
  },

  getByMenuId: async (menuId: number) => {
    return await request.get({ url: `/cms/content-text/getLastByMenuId?menuId=${menuId}` })
  },

  // 新增文本内容
  createContentText: async (data: ContentTextVO) => {
    return await request.post({ url: `/cms/content-text/save`, data })
  },

  // 提交审批文本内容
  submitContentText: async (data) => {
    return await request.put({ url: `/cms/content-text/submit?id=${data.id}` })
  },

  // 修改文本内容
  updateContentText: async (data: ContentTextVO) => {
    return await request.put({ url: `/cms/content-text/update`, data })
  },

  // 删除文本内容
  deleteContentText: async (id: number) => {
    return await request.delete({ url: `/cms/content-text/delete?id=` + id })
  },

  // 导出文本内容 Excel
  exportContentText: async (params) => {
    return await request.download({ url: `/cms/content-text/export-excel`, params })
  },
}
